package it.fuzzylogics.fuzzywidgetsLibrary.client.FuzzyListeners;

import com.google.gwt.user.client.Element;


public class FMouseLeaveListener {
    public FMouseLeaveListener(Element e, FMouseLeaveHandler handler) {
        attachMouseLeaveHandler(e, handler);
    }

    public static void setMouseLeaveEvent(Element e, FMouseLeaveHandler handler) {
        new FMouseLeaveListener(e, handler);
    }

    private static native void dispatchMouseLeaveHendler(FMouseLeaveHandler handler) /*-{
            handler.@it.fuzzylogics.fuzzywidgetsLibrary.client.FuzzyListeners.FMouseLeaveHandler::onMouseLeave()();
      }-*/;

    private native void attachMouseLeaveHandler(Element e, FMouseLeaveHandler handler) /*-{

         e.onmouseout = handler;

               if ($wnd.addEventListener && !$wnd.opera) {
                   e.addEventListener('onmouseout', @it.fuzzylogics.fuzzywidgetsLibrary.client.FuzzyListeners.FMouseLeaveListener::dispatchMouseLeaveHendler(Lit/fuzzylogics/fuzzywidgetsLibrary/client/FuzzyListeners/FMouseLeaveHandler;), false);
               }

          e.onmouseout = function() {

                   @it.fuzzylogics.fuzzywidgetsLibrary.client.FuzzyListeners.FMouseLeaveListener::dispatchMouseLeaveHendler(Lit/fuzzylogics/fuzzywidgetsLibrary/client/FuzzyListeners/FMouseLeaveHandler;)(handler);

          }

      }-*/;
}
